#include <iostream>

using namespace std;

int array_minimum(int* number_array, unsigned int n, unsigned int k = 1);

int main() {
	unsigned int n, k;
	cin >> n >> k;
	int* number_array = new int[n];
	for (unsigned int i = 0; i < n; i++) {
		cin >> *(number_array + i);
	}
	cout << array_minimum(number_array, n, k);
	delete[] number_array;
}

int array_minimum(int* number_array, unsigned int n, unsigned int k) {
	for (unsigned int i = 0; i < k; i++) {
		int index = i, minimum = 5000;
		for (unsigned int j = i; j < n; j++) {
			if (*(number_array + j) < minimum) {
				index = j;
				minimum = *(number_array + j);
			}
		}
		*(number_array + index) = *(number_array + i);
		*(number_array + i) = minimum;
	}
	return *(number_array + k - 1);
}